<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Jet-CMS | Dashboard</title>
    <link type="text/css" rel="stylesheet" th:href="@{/pure-min.css}" />
    <link type="text/css" rel="stylesheet" th:href="@{/main.css}" />
    <script type="text/javascript" th:src="@{/vue-min.js}"></script>
    <style>
        .menu {
            margin-top: 20px;
        }
        .menu a {
            display: block;
            margin: 10px;
            padding: 20px;
            background: linear-gradient(to left top, #eeeeee, #f9f9f9);
            text-align: center;
            border-radius: 8px;
            text-decoration: none;
            box-shadow: 2px 2px 4px #ddd;
        }
        .menu a:hover {
            background: linear-gradient(to left top, #c0edff, #f9f9f9);
        }
        .menu a img {
            width: 50%;
        }
        .menu-name {
            font-size: 16px;
            color: #666;
            padding: 6px 0 4px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div id="app">
        <span th:include="home/_nav"></span>
        <div class="container">
            <div class="alert alert-info">
                <p>
                    <b>拥有权限：</b>{{roleText}} |
                    <b>最后登录时间：</b><span th:text=${session.activeTime}></span> |
                    <b>最后登录地址：</b><span th:text="${session.ip}"></span>
                </p>
                <p>
                    <b>服务器时间：</b>(北京) <span th:text="${datetime}"></span> |
                    <b>时间戳：</b><span th:text="${timestamp}"></span>
                </p>
            </div>
            <div class="menu">
                <div class="pure-g">
                    <div class="pure-u-1-6">
                        <a th:href="@{/home/channel}">
                            <img th:src="@{/images/ic-folder.png}" />
                            <div class="menu-name">栏目</div>
                        </a>
                    </div>
                    <div class="pure-u-1-6">
                        <a href="/home/resource">
                            <img th:src="@{/images/ic-video.png}" />
                            <div class="menu-name">资源</div>
                        </a>
                    </div>
                    <div class="pure-u-1-6">
                        <a href="/home/comment">
                            <img th:src="@{/images/ic-message.png}" />
                            <div class="menu-name">评论</div>
                        </a>
                    </div>
                    <div class="pure-u-1-6">
                        <a href="/home/user">
                            <img th:src="@{/images/ic-users.png}" />
                            <div class="menu-name">用户</div>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script>
    const vue = new Vue({
        el: '#app',
        data: {
            role: '[[${session.role}]]',
            roleField: {
                1: '内容',
                2: '资源',
                4: '用户',
                8: '特需'
            },
            roleText: ''
        },
        methods: {
            init: function() {
                let role = parseInt(this.role);
                let roleText = [];
                for(let i in this.roleField) {
                    if (role & i) {
                        roleText += this.roleField[i] + ' ';
                    }
                }
                this.roleText = roleText;
            }
        }
    });
    vue.init();
</script>
</html>